﻿@model Clirelmgt.Models.NewObject
@{
    ViewBag.Title = "Edit Object Description";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

<script type="text/javascript">
    function showTables()
    {
        document.getElementById('divTable').style.display = '';
        if (document.getElementById('ObjectType').value == 'TABLE') {
            document.getElementById('divTable').style.display = 'none';
        }
    }
</script>

<div class="dashboard-wrapper">
    <div class="left-sidebar">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget">
                    <div class="widget-header">
                        <div class="title">
                            Edit object description
                        </div>
                    </div>
                    <div class="widget-body">
                        <form class="form-horizontal no-margin" method="post">
                            <div class="control-group">
                                <label class="control-label" for="name">
                                    Module
                                </label>
                                <div class="controls controls-row">
                                    <select id="Module" name="Module">
                                        @foreach (KeyValuePair<int, string> item in Model.Modules)
                                        {
                                            if (item.Key == Model.SelectedModule)
                                            {
                                                <option value="@item.Key" selected="selected">@item.Value</option>
                                            }
                                            else
                                            {
                                                <option value="@item.Key">@item.Value</option>
                                            }
                                        }
                                    </select>
                                    <span class="field-validation-valid" data-valmsg-for="Module" data-valmsg-replace="true"></span>
                                </div>
                            </div>
                            
                            @if(Request.QueryString["type"].ToUpperInvariant() != "TABLE")
                            {
                                <div class="control-group" id="divTable">
                                    <label class="control-label" for="name">
                                        Link Table
                                    </label>
                                    <div class="controls controls-row">
                                        <select id="LinkTable" name="LinkTable">
                                            @foreach (string item in Model.Tables)
                                            {
                                                if (item.ToUpperInvariant() == Model.SelectedTable.ToUpperInvariant())
                                                {
                                                    <option value="@item" selected="selected">@item</option>    
                                                }
                                                else
                                                {
                                                    <option value="@item">@item</option>    
                                                }
                                            }
                                        </select>
                                        <span class="field-validation-valid" data-valmsg-for="ObjectType" data-valmsg-replace="true"></span>
                                    </div>
                                </div>
                            }
                            <div class="control-group">
                                <label class="control-label" for="name">
                                    Name
                                </label>
                                <div class="controls controls-row">
                                    <input class="span5" type="text" id="Name" name="Name" data-val="true" data-val-required="Required!" value="@Model.Name" />
                                    <span class="field-validation-valid" style="color:red; font-size:11px; margin-left:5px;" data-valmsg-for="Name" data-valmsg-replace="true"></span>
                                </div>
                            </div>
                            <div class="form-actions no-margin">
                                
                                <button name="BtnDelete" type="submit" class="btn btn-info pull-right" style="margin-left:10px;">
                                    Delete
                                </button>
                                
                                <button name="BtnUpdate" type="submit" class="btn btn-info pull-right">
                                    Update
                                </button>
                                
                                <div class="clearfix">
                                </div>
                            </div>

                        </form>

                    </div>
                </div>
            </div>

        </div>
    </div>

</div>
